<div id="content">
    <div id="page-heading"><h1>Nhận xét sản phẩm</h1></div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized"><img src="<?= base_url(); ?>images/admin_img/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized"><img src="<?= base_url(); ?>images/admin_img/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <!--  start content-table-inner -->
                <div id="content-table-inner">
                    <div class="table-content">
                        <div class="search">
                            <form namr="fr-search" id="fr-search" method="post" action="<?= base_url(); ?>dienhoa-administrator/san_pham/tat_ca_sp">
                                <ul class="ul-search">
                                    <li>Tên sản phẩm: </li>
                                    <li><input type="text" name="txtName" value=""/></li>
                                    <li><input type="submit" name="btnSend" value="Tìm"/></li>
                                </ul>
                            </form>
                            <div class="clear"></div>
                        </div>
                        <div class="tb_TCHoaDon">
                            <form name="formHD" id="formHD" action="<?= base_url(); ?>dienhoa-administrator/san_pham/xoa" method="post">
                                <table class="table_infor">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>Tên sản phẩm</th>
                                            <th>Chi tiết</th>
                                        </tr>
                                    </thead>
                                    <tbody id="bd-hd">
                                        <? foreach ($cm_infor as $rows2): ?>
                                            <tr class="sp">
                                                <td class="Ngay"><?= $rows2->CmID; ?></td>
                                                <td class="Ngay"><?= $rows2->FName; ?></td>
                                                <td>
                                                    <a class="xem bo_<?= $rows2->FID; ?>"  id="<?= $rows2->FID; ?>"  href="<?= base_url(); ?>dienhoa-administrator/comment/xu_ly_cm/<?= $rows2->FID; ?>">Xem</a>
                                                </td>

                                            </tr>
                                            <tr>
                                                <td colspan="3" align="center" class="wait loading_<?= $rows2->FID; ?>"><img src='<?= base_url(); ?>images/ajax-loader.gif' width='20' height='20'/></td>
                                                <td id="cm_<?= $rows2->FID; ?>" style="display: none;" colspan="3">
                                                    <table>
                                                        <tr>
                                                            <td>
                                                                <div id="show_<?= $rows2->FID ?>" class="frame_com">
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        <? endforeach; ?>
                                    </tbody>
                                    <tfoot>
<!--                                        <tr>
                                            <td colspan="6" style="width: 50px;"><div class="phan_trang"><?= $pagination; ?></div></td>
                                        </tr>-->
                                    </tfoot>
                                </table>
                            </form>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                <!--  end content-table-inner  -->
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>

    <div class="clear">&nbsp;</div>

</div>
<script type="text/javascript">
    function proccessForm2(id,string,getID){
        setTimeout(function(){
            $("#show_"+id).html(string);
            $(".LoadHide").hide();
            $("#cm_"+id).slideDown("slow");
            $(".loading_"+id).hide();
            $("#cm_"+getID).hide();
        },1000);
        
    }
    
    function LoadComment(getID,link,id){
        //            console.log(getID);   
        $.ajax({
            url: link,
            type: "GET",
            async: false,
            beforeSend: function(){
                $(".loading_"+id).show();
            },
            success: function(string){
                proccessForm2(id,string,getID);
            },
            error: function(){
                alert('Co loi xay ra');
            }
        });
    }
    //thuc thi request xoa
    function DelComAjax(html,idView){
        setTimeout(function(){
            if(parseFloat(html)){
                alert("không xóa được!");
            }else{
                $("#show_"+idView).html(html);
            }
        },1000);
    }
    //fc xoa
    function XoaCom(idV){
        $(".del_com a").live("click",function(eve){
            eve.preventDefault();
            var urlDel = $(this).attr("href");
            var cmid = $(this).attr("id");
            $.ajax({
                url: urlDel,
                type: "GET",
                async: false,
                beforeSend: function(){
                    $("#show_"+idV).prepend("<img class='imgLoad' src='<?= base_url(); ?>images/ajax-loader.gif' width='20' height='20'/>");
                },
                success: function(html){
                    DelComAjax(html,idV);
                },
                error: function(){
                    alert("khong gui request xoa duoc");
                }
            });
        });
    }
    
    $(document).ready(function(){
        var getID = "";
        var idbtn = ""
        $(".wait").hide();
        //load comment
        $(".xem").bind("click",function(eve){
            eve.preventDefault();
            var link = $(this).attr("href");
            var id = $(this).attr("id");
            $(this).addClass("hide").removeClass("active");
            $("#"+getID).addClass("active").removeClass("hide");
            //            console.log(id);
            LoadComment(getID,link,id);
            XoaCom(id);
            //            console.log(getID);
            getID = id;
        });
    });
    
</script>